﻿namespace AC.ExtendedRenderer.Toolkit
{
    using AC.ExtendedRenderer.Toolkit.Utils;
    using ComponentFactory.Krypton.Toolkit;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;

    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All), ToolboxBitmap(typeof(ComboBox))]
    public class KryptonComboBoxToolStripMenuItem : ToolStripControlHostFixed
    {
        public event System.EventHandler SelectedIndexChanged;

        public KryptonComboBoxToolStripMenuItem() : base(new ComponentFactory.Krypton.Toolkit.KryptonComboBox())
        {
            base.AutoSize = false;
        }

        public override Size GetPreferredSize(Size constrainingSize)
        {
            return this.KryptonComboBoxControl.GetPreferredSize(constrainingSize);
        }

        protected void OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.SelectedIndexChanged != null)
            {
                this.SelectedIndexChanged(this, e);
            }
        }

        protected override void OnSubscribeControlEvents(Control control)
        {
            base.OnSubscribeControlEvents(control);
            ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) control).SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged);
        }

        protected override void OnUnsubscribeControlEvents(Control control)
        {
            base.OnUnsubscribeControlEvents(control);
            ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) control).SelectedIndexChanged += new System.EventHandler(this.OnSelectedIndexChanged);
        }

        [RefreshProperties(RefreshProperties.All), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ComponentFactory.Krypton.Toolkit.KryptonComboBox KryptonComboBoxControl
        {
            get
            {
                return (base.Control as ComponentFactory.Krypton.Toolkit.KryptonComboBox);
            }
        }

        public int SelectedIndex
        {
            get
            {
                return ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedIndex;
            }
            set
            {
                ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedIndex = value;
            }
        }

        public string SelectedText
        {
            get
            {
                return ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedText;
            }
            set
            {
                ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedText = value;
            }
        }

        public object SelectedValue
        {
            get
            {
                return ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedValue;
            }
            set
            {
                ((ComponentFactory.Krypton.Toolkit.KryptonComboBox) base.Control).SelectedValue = value;
            }
        }
    }
}

